#include"comm.hpp"

int main()
{
    key_t k= ftok(PATH_NAME,PROJ_ID);
    if(k<0)
    {
        Log("create lkey failed",ERROR)<<"Client key : "<< k << endl;
        exit(1);
    }
    Log("create lkey done",Debug)<<"shmClient key : "<< k << endl;
//获取共享内存
    int shmid=shmget(k,SHM_SIZE,0);
    if(shmid<0)
    {
        Log("create lkey Failed",ERROR)<<"Client key : "<< k << endl;
        exit(2);
    }
    Log("create success",ERROR)<<"Clent key : "<< k << endl;
    sleep(10);

    char* shmaddr=(char*)shmat(shmid,nullptr,0);
    if(shmaddr==nullptr)
    {
        Log("attach shm failed",ERROR)<<"Client key : "<< k << endl;
        exit(3);
    }
    Log("atacgh success",ERROR)<<"Clent key : "<< k << endl;
    sleep(10);

    //使用

    //去关联
    int n=shmdt("shmaddr");
    assert(n!=-1);
    Log("detach success",ERROR)<<"Clent key : "<< k << endl;
    sleep(10);

    return 0;
}